<template>
  <div>
     <div class="config">
        <div class="back" onclick="window.history.go(-1)"><img src="../assets/images/back.png" alt=""></div>
        <p>消费记录</p>
    </div>
    <div class="header">
        <select name="" id="" v-model="month" class="select1" @change="change()">
            <option value="1">{{year}}-1</option>
            <option value="2">{{year}}-2</option>
            <option value="3">{{year}}-3</option>
            <option value="4">{{year}}-4</option>
            <option value="5">{{year}}-5</option>
            <option value="6">{{year}}-6</option>
            <option value="7">{{year}}-7</option>
            <option value="8">{{year}}-8</option>
            <option value="9">{{year}}-9</option>
            <option value="10">{{year}}-10</option>
            <option value="11">{{year}}-11</option>
            <option value="12">{{year}}-12</option>          
        </select>
        <select name="" id="" v-model="table" class="select2" @change="change()">
            <option value="0">消费信息</option>
            <option value="1">招商信息</option>
            <option value="2">提额信息</option>
            
        </select>
        
    </div>
      <div class="box"> 
        <div class="row" v-for="item in data">             
            <p>{{item.des}}</p>
            <p>{{item.create_time}}</p>
            <span>＋¥ {{item.price}}</span>
        </div> 
        <p class="none" v-show="data.length==0">暂无记录</p>


          
  
     </div>
 


  </div>
</template>

<script>
export default {
    name: "mouthIncome",
    data() {
        return {
            year: "",
            month: "",
            table: 0,
            data: {}
        };
    },
    beforeCreate() {
        document.getElementsByTagName("body")[0].style.background = "#ececec";
    },
    methods: {
        select() {
            var qs = require("qs");
            this.axios({
                method: "post",
                url: `${this.siteUrl}/getIncome`,
                data: qs.stringify({
                    uid: localStorage.getItem("uid"),
                    year: this.year,
                    month: this.month,
                    table: this.table
                })
            })
                .then(response => {
                
                    if ((response.data.result == 200)) {
                        this.data = response.data.data;
                    } else {
                        alert("请求失败");
                    }
                })
                .catch(function(error) {
                    console.log(error);
                });
        },
        change() {
            this.select();
        }
    },
    mounted() {
        var date = new Date();
        this.month = date.getMonth() + 1;
        this.year = date.getFullYear();
        this.select();
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.header {
    height: 120px;
    background: #5aa0c8;
    position: relative;
    z-index: 1;
}

.box {
    width: 94%;
    margin-left: 3%;

    border-radius: 3px;
    background: #fff;
    margin-top: -40px;
    overflow: hidden;
    z-index: 99;
    position: relative;
}


.row {
    min-height: 60px;
    background: #fff;
    position: relative;
    border-bottom: 1px solid #f2f2f2;
    margin: 8px;
}

.row span {
    position: absolute;
    height: 12px;
    top: 13px;
    right: 17px;
    color: #5aa0c8;
}

.row p:first-child {
    margin-left: 10px;
    margin-top: 5px;
    font-size: 14px;
    width: 70%;
}
.row p:nth-child(2) {
    margin-left: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}
.select1 {
    position: absolute;
    top: 30px;
    width: 100px;
    border: none;
    height: 25px;
    left: 15%;
}
.select2 {
    position: absolute;
    top: 30px;
    width: 100px;
    border: none;
    height: 25px;
    right: 15%;
}
.none{
    height: 60px;
    line-height: 60px;
    text-indent: 10px;
}
</style>
